Skip to content

Conversation

@lodekeeper
Copy link

Description

Fixes the failing lightclient e2e test after upgrading to electra.

Root Cause

The test incorrectly assumed sync committees would have alternating pubkeys [pk0, pk1, pk0, pk1, ...]:

const committeePubkeys = Array.from({length: SYNC_COMMITTEE_SIZE}, (_, i) =>
  i % 2 === 0 ? pubkeys[0] : pubkeys[1]
);

However, sync committees are computed using a weighted random shuffle based on:

  • A seed derived from the state
  • Validator effective balances

Why it broke post-electra

In getNextSyncCommitteeIndices(), the shuffle parameters changed for electra:

if (fork >= ForkSeq.electra) {
  maxEffectiveBalance = MAX_EFFECTIVE_BALANCE_ELECTRA;  // Different!
  randByteCount = 2;  // Different! (was 1)
}

The shuffle algorithm now uses 2 random bytes instead of 1, producing a completely different committee distribution even with the same validators.

Fix

Get the actual sync committee root from the head state instead of constructing an incorrect expected committee.

Closes #8723


Note

This PR was authored by Lodekeeper (AI assistant) under supervision of @nflaig.

@lodekeeper lodekeeper requested a review from a team as a code owner January 31, 2026 15:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lodekeeper, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue in the light client committee root end-to-end test that emerged following the Electra upgrade. The previous test logic incorrectly assumed a simple alternating pattern for sync committee public keys, which is not how committees are formed in practice, especially with the changes introduced in Electra. The fix updates the test to dynamically retrieve the actual sync committee root from the beacon node's head state, ensuring the test accurately reflects the network's behavior and passes reliably.

Highlights

  • Test Fix for Electra Upgrade: Corrected a failing end-to-end test for the getLightClientCommitteeRoot endpoint, which broke after the Electra upgrade.
  • Corrected Sync Committee Root Calculation: The test now accurately determines the expected sync committee root by fetching it directly from the beacon node's head state, rather than relying on an incorrect, hardcoded assumption about public key distribution.
  • Removed Outdated Logic: Eliminated the previous logic that assumed sync committee public keys would alternate between two validators, which was not aligned with the weighted random shuffle mechanism.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request provides a solid fix for a failing lightclient e2e test that occurred after the Electra upgrade. The root cause was an incorrect assumption in the test about how sync committees are constructed. The new implementation correctly fetches the expected committee root directly from the head state, making the test more robust and accurate. The code is clean, the change is well-contained, and the removal of now-unnecessary code and imports is a good cleanup. Overall, this is an excellent contribution.

The test incorrectly assumed sync committees would have alternating
pubkeys [pk0, pk1, pk0, pk1, ...], but sync committees are computed
using a weighted random shuffle based on validator effective balances
and a seed.

Post-electra, the shuffle algorithm uses 16-bit random values (vs 8-bit
pre-electra) and MAX_EFFECTIVE_BALANCE_ELECTRA, producing different
committee distributions.

Fix: Get the actual sync committee root from the head state instead of
constructing an incorrect expected committee.

Closes ChainSafe#8723
@lodekeeper lodekeeper force-pushed the lodekeeper/fix-lightclient-e2e-test branch from 4107e79 to 99941e8 Compare January 31, 2026 15:52
@lodekeeper lodekeeper changed the title fix: correct lightclient committee root test for electra test: correct lightclient committee root test for electra Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed lightclient e2e test post-electra

1 participant